/**
 * 
 */

/**
 * @author osamie
 *
 */
public class Choice extends Operator {
	
    
	/**
     * Return the number of arguments this operator takes
     */
    public int nArguments() {
	return 3;
    }

    /**
     * Evaluate this operator on the given expression
     * @throws ParseException 
     */
    public Data evaluate(Data args[]) throws TypeException {
	
    	
    if (!(args[0] instanceof BooleanData)) {
	    throw new TypeException(getClass().getName()
				+ ": first argument is not boolean");
	}
    boolean b = ((BooleanData)args[0]).value;
    
    
    if(b) return args[1];
    
    else return args[2];
    
    
    
    
    
    
	
    
    	
    
    }

    /**
     * Return a string representation of this operator
     */
    public String toString() {
	return "?";
    }
}
